package net.xo68.destiny.starter.common.sched;

import net.xo68.destiny.contract.domain.job.TriggerParameter;
import net.xo68.destiny.core.timingwheel.Timeout;
import net.xo68.destiny.core.timingwheel.TimingWheelTaskSequencer;

import java.util.Set;
import java.util.concurrent.TimeUnit;

/**
 * 命运调度
 * @desc 负责任务的调度
 * @author wuxie
 * @version 2020-12-24
 */
public interface DestinyTimingWheelScheduler {


    /**
     * 关闭
     */
    Set<Timeout<TriggerParameter>> shutdown();

    /**
     * 推入时光轮缓存队列
     * @param triggerParameter
     * @param delay 延时时间
     * @param unit
     * @return
     */
    Timeout<TriggerParameter> newTimeout(TriggerParameter triggerParameter, long delay, TimeUnit unit);

    /**
     * 取消息超时项
     * @param taskSequence
     * @return
     */
    boolean cancelTimeout(String taskSequence);

    TimingWheelTaskSequencer<TriggerParameter> getSequencer();
}
